import QtQuick 1.0
import Kookaburra 1.0

Item {
    property string source

    width: map.width

    id: mapObject

    TileMap {
        source: parent.source

        id: map

        /* LoadGameObjects: dynamically instantiates game objects read from map file */
        function loadGameObjects() {
            var objs = readGameObjects();
            var component;

            for (var i = 0; i < objs.length; i++) {
                component = Qt.createComponent(objs[i].type + ".qml");
                if (component.status == Component.Ready) {
                    component.createObject(mapObject, { x: objs[i].x, y: 470, z: 10, paused: mapObject.parent.paused });
                }
            }
        }

        Component.onCompleted: {
            loadGameObjects();
        }
    }
}
